import json
import re
import requests
base_url = "https://www.hbjcxy.com/jyyw/"
# 请求
response = requests.get(base_url)
response.encoding = "utf-8"
pattern = r'list-title">[\s\S]*?>([\s\S]*?)</a>'
pattern1 = r'list-title">.*?>(.*?)</a>'
pattern_date = r'"list-meta">([\s\S]*?)</div>'
# 使用正则匹配
res = re.findall(pattern,response.text)
res1 = re.findall(pattern1,response.text,re.S)
res_date = re.findall(pattern_date,response.text)
print(res)
print(res1)
print(res_date)
data = []
for i in range(len(res)):
    d = {"标题":str(res[i]).strip(),
         "时间":str(res_date[i]).strip()}
    data.append(d)
print(data)
# 写入文件
with open("1.json","w+",encoding="utf-8") as f:
    f.write(json.dumps(data,ensure_ascii=False,indent=2))